package com.trendit.print.sdk.models.printer;

import com.trendit.print.sdk.DaquObject;
import com.trendit.print.sdk.DaquRequest;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * 小票打印请求
 */
@Data
public class DoPrintRequest implements DaquRequest<DoPrintResponse> {
    private DaquObject bizModel;

    /**
     * 构造方法
     * @param bizModel
     */
    public DoPrintRequest(DoPrintRequest.Model bizModel) {
        this.bizModel = bizModel;
    }

    @Override
    public String getApiMethodName() {
        return "openapi.print";
    }

    @Override
    public String getApiVersion() {
        return "1.0";
    }

    @Override
    public String getNotifyUrl() {
        return null;
    }

    @Override
    public String getApiMethodURL() {
        return "/openapi/print";
    }

    @Override
    public Class<DoPrintResponse> getResponseClass() {
        return DoPrintResponse.class;
    }

    @Override
    public DaquObject getBizModel() {
        return bizModel;
    }

    @Override
    public String getBizContent() {
        return null;
    }

    @Data
    public static class Model extends DaquObject {
        /**
         * 设备编码
         */
        @NotNull
        private String sn;

        /**
         * 业务单号（可选，协助定位问题）
         */
        @NotNull
        private String orderId;

        /**
         * 小票内容，限8K
         */
        @NotNull
        private String content;

        /**
         * 联数
         */
        @NotNull
        private Integer copies = 1;

        /**
         * 语音内容
         */
        private String voice;

        /**
         * 语音播报次数
         */
        private Integer voicePlayTimes = 1;

        /**
         * 语音播报间隔
         */
        private Integer voicePlayInterval = 3;

        /**
         * 超时时间：小时 （以接收到的时间开始叠加时长。）
         * 默认值：2小时
         */
        @Min(2)
        @Max(24)
        private int expiredHour;
    }
}
